package com.ruoyi.web.service.lmpl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.web.entity.*;
import com.ruoyi.web.mapper.MeterApiMapper;
import com.ruoyi.web.service.MeterApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 实时查询实现类
 *
 * @author sun
 * @date 2019/6/10 9:14
 */
@Service
public class MeterApiServiceImpl implements MeterApiService {

	@Autowired
	private MeterApiMapper meterApiMapper;

	@Override
	@DataSource(value = DataSourceType.SLAVE)
	public List<Meter> getMeteListByAreaCode(String areaCode){
		return meterApiMapper.getMeteListByAreaCode(areaCode);
	}

	@Override
	@DataSource(value = DataSourceType.SLAVE)
	public Result getDataListByMeterAdd(String[] meterAdds, String startTime, String endTime, Integer datatType){
		if(datatType==1){
			List<ReadingDay> readingDayList= meterApiMapper.getFreezeDayByMeterAdd(meterAdds,startTime,endTime);
			return Result.success(readingDayList);
		}else if(datatType==2){
			List<ReadingMonth> readingMonthList=meterApiMapper.getFreezeMonthByMeterAdd(meterAdds,startTime,endTime);
			return Result.success(readingMonthList);
		}else{
			return Result.fail(HttpStatusEnum.BAD_REQUEST);
		}

	}


}
